package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.OpenAdvertising
import com.ruoyi.back.domain.vo.UrlGoal
import com.ruoyi.back.service.OpenAdvertisingService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("system/openAdvertising")
@Api(tags = ["广告管理-开屏广告-...-个人中心"])
class OpenAdvertisingController {

    @Autowired
    private lateinit var openAdvertisingService: OpenAdvertisingService


    @ApiOperation("保存广告")
    @PostMapping("save")
    fun saveOpenAdvertising(@RequestBody openAdvertising: OpenAdvertising): Data<Boolean> = openAdvertisingService.saveOpenAdvertising(openAdvertising)


    @ApiOperation("广告分页")
    @GetMapping("list")
    fun openAdvertisingPage(advertising: OpenAdvertising): PageData<OpenAdvertising> = openAdvertisingService.openAdvertisingPage(advertising).pageInfo()


    @ApiOperation("获取链接目标集合")
    @GetMapping("urlGoalList")
    fun urlGoalList(): Data<List<UrlGoal>> = openAdvertisingService.urlGoalList()

    @ApiOperation("批量移除广告")
    @ApiImplicitParams(
        ApiImplicitParam(name = "advertisingIds", value = "广告id 多个使用逗号", type = "path", required = true)
    )
    @GetMapping("remove/{advertisingIds}")
    fun removeOpenAdvertising(@PathVariable advertisingIds: String): Data<Boolean> = openAdvertisingService.removeOpenAdvertising(advertisingIds)
}